from celery import Celery
import os

broker = 'redis://124.221.242.12:63379/1'  # 消息中间件 redis
backend = 'redis://124.221.242.12:63379/2'  # 结果存，用redis
app = Celery('app', broker=broker, backend=backend, include=['celery_task.home_task', 'celery_task.user_task'])
# django中使用celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'luffy_api.settings.dev')
# 时区
app.conf.timezone = 'Asia/Shanghai'
# 是否使用UTC
app.conf.enable_utc = False

# 任务的定时配置
from datetime import timedelta
from celery.schedules import crontab

app.conf.beat_schedule = {
    '': {
        'task': '',
        'schedule': timedelta(seconds=3),  # 每3秒
        # 'schedule': crontab(hour=8, day_of_week=1),  # 每周一早八点
        'args': (),
    }
}
